 <template>
  <div class="operationList">
    <filterPanel filterName="SOperationListFilter" filterTitle="运营查询" :filterList="filterData"
                 @filterChange="filterChange"></filterPanel>
    <tablePanel tableName="SOperationListTable" :tableLoading="loading" tableTitle="运营列表" :tableList="tableList"
                :tableData="tableData" :total="total" :currentPage="form.page_start" :pageSize="form.page_size"
                @sizeChange="sizeChange" @pageChange="pageChange" @tableClick="tableClick">
    </tablePanel>
  </div>
</template>

<script>
	export default {
		name: "SOperationList",
		props: {},
		data() {
			return {
				filterData: [
					{
						title: '姓名',
						name: 'empname',
						type: 'input',
						value: '',
            maxlength:'50',
						isShow: true,
						isSelected: true
					},
					{
						title: '性别',
						name: 'sex',
						type: 'select',
						optionList: [
							{label: '全部', value: ''},
							{label: '男', value: '1'},
							{label: '女', value: '2'},
						],
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '电话',
						name: 'employee_mobile',
						type: 'input',
						value: '',
						maxlength:'11',
						isShow: true,
						isSelected: true
					},
					{
						title: '身份证号',
						name: 'name',
						type: 'input',
						value: '',
						maxlength:'18',
						isShow: true,
						isSelected: true
					},
					{
						title: '工作状态',
						name: 'status',
						type: 'select',
						optionList: [
							{label: '全部', value: ''},
							{label: '在职', value: '0'},
							{label: '离职', value: '1'},
							// {label: '入职中', value: '2'},
						],
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '入职时间',
						name: 'time',
						type: 'date',
						value: [],
						isShow: true,
						isSelected: true
					},
				],
				form: {
					status: "",
					time: [],
					page_start: 1,
					page_size: 10
				},
				loading: false,
				tableList: [
					{
						title: '姓名',
						width: 120,
						name: 'employee_name',
						isShow: true,
						isSelected: true
					},
					{
						title: '性别',
						width: 120,
						name: 'sex',
						isShow: true,
						isSelected: true
					},
					{
						title: '电话',
						width: 120,
						name: 'employee_mobile',
						isShow: true,
						isSelected: true
					},
					{
						title: '入职时间',
						width: 120,
						name: 'create_time_vis',
						isShow: true,
						isSelected: true
					},
					{
						title: '身份证号',
						width: 120,
						name: 'card_no',
						isShow: true,
						isSelected: true
					},
					{
						title: '工作状态',
						width: 120,
						name: 'status',
						isShow: true,
						isSelected: true
					},
					{
						title: '揽件数量',
						width: 120,
						name: 'lsize',
						isShow: true,
						isSelected: true
					},
				],
				tableData: [],
				total: 0,
			};
		},
		computed: {
			postData() {
				let data = {
					...this.form,
					pagination: {
						page_start: this.form.page_start,
						page_size: this.form.page_size
					}
				};
				if (this.form.time && this.form.time.length > 0) {
					data.begin_time = this.$Timestamp(this.form.time[0]);
					data.end_time = this.$Timestamp(this.form.time[1]);
				}
				return data;
			},
		},
		watch: {},
		components: {},
		methods: {
			sizeChange(val) {
				this.form.page_size = val;
				this.getData()
			},
			pageChange(val) {
				this.form.page_start = val;
				this.getData()
			},
			filterChange(data) {
				this.form = {...this.form, ...data};
				this.getData();
			},
			getData() {
				this.loading = true;
				this.$axios.post(this.$api.reportEmployeeLogist, this.postData).then(res => {
					let {code, msg, data} = res;
					this.loading = false;
					if (code == 200) {
						this.tableData = data.list.filter(item => {
							let sexList = ["保密", "男", "女"],
								statusList = ['入职中', '在职', '离职'];
							item.sex = sexList[item.sex];
							item.status = statusList[item.status];
							return item;
						});
						this.total = data.pagination.total_count || 0;
					} else {
						this.total = 0;
						this.tableData = [];
					}
				}).catch(ret => {
					this.loading = false;
					this.$message.error(ret.msg || '服务繁忙，请稍后再试');
				});
			},
			tableClick(data, type) {
			},
		},
		mounted() {
			this.getData()
		},
		created() {
		}
	}
</script>

<style scoped lang="less" src="@/style/sorting/operation/operationList/index.less">

</style>
